package ln.frame.prac.microprofile.config.converter;

import org.eclipse.microprofile.config.spi.Converter;

public abstract class AbstractConverter<T> implements Converter<T> {

    @Override
    public T convert(String s) throws IllegalArgumentException, NullPointerException {
        if(s == null) {
            throw new NullPointerException("The value must not be null!");
        }
        T re;
        try {
            re = doConvert(s);
        } catch (Throwable e) {
            throw new IllegalArgumentException("The value cannot be converted. ", e);
        }
        return re;
    }

    public abstract T doConvert(String s) throws Throwable;
}
